#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<linux/input.h>
#include"mpu6050_driver.h"

int main(int argc, const char **argv)
{
    int fd = -1;
    union mpu6050_data data;
    if(argc < 2)
    {
        printf("Argument is not enough\n");
        return 1;
    }

    fd = open(argv[1], O_RDONLY);
    if(fd < 0)
    {
        perror("open");
        return 2;
    }

    while(1)
    {
        sleep(2);
        ioctl(fd, GET_ACCEL, &data);
        printf("accel-x:%d\n", data.accel.x);
        printf("accel-y:%d\n", data.accel.y);
        printf("accel-z:%d\n", data.accel.z);
        ioctl(fd, GET_GYRO, &data);
        printf("gyro-x:%d\n", data.gyro.x);
        printf("gyro-y:%d\n", data.gyro.y);
        printf("gyro-z:%d\n", data.gyro.z);
        ioctl(fd, GET_TEMP, &data);
        printf("temp:%d\n", data.temp);
    }

    close(fd);
    fd = -1;

    return 0;
}